<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <div id="div1"></div>
    <script type="text/javascript">
        window.onload = function () {
            var div1 = document.getElementById("div1");
            function timego() {
                var now = new Date();
                var year = now.getFullYear();
                var month = now.getMonth()+1;
                var day = now.getDate();
                var week = now.getDay();//获取周信息
                var hours = now.getHours();
                var minutes = now.getMinutes();
                var seconds = now.getSeconds();
                var str = "当前事件为："+year+"-"+month+"-"+day+" "+hours+":"+minutes+":"+seconds;
                div1.innerHTML = str;
            }
            timego();
            setInterval(timego,1000);
        }

    </script>
</body>
</html>